package com.shadow.cloud.security.controller;

import com.shadow.cloud.common.bo.R;
import com.shadow.cloud.security.entity.UserEntity;
import com.shadow.cloud.security.service.UserService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@AllArgsConstructor
@RestController
@RequestMapping("/user/")
public class UserController {

    private final UserService userService;

    @GetMapping("/getUserList")
    public R getUserList(@RequestParam String orgId) {
        List<UserEntity> list = userService.getUserList(orgId);
        return R.success(R.SUCCESS_MSG, list);
    }

    @GetMapping("/login/{username}")
    public UserEntity selectByAccount(@PathVariable("username") String username){
        return userService.selectByAccount(username);
    }

    @GetMapping("/permission/{userId}")
    public List<String> selectUserPermissions(@PathVariable("userId") String userId){
        return userService.selectUserPermissions(userId);
    }
}
